<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="../js/vue.js" type="text/javascript"></script>
<body>

    <div id="app">
        <h2>{{msg}}</h2>
		<h2>今天天气很{{info}}</h2>
		<button @click="changeWeather">切换天气</button>
    </div>
    
</body>
<script>
	new Vue({
		el:'#app',
		data:{
			msg:'监视属性-简写',
			isHot:true
		},
		computed:{
			info(){
				return this.isHot ? '炎热' : '寒冷'
			}
		},
		methods: {
			changeWeather(){
				this.isHot = !this.isHot
			}
		},
		watch:{
			//正常写法
			// isHot:{
			// 	immediate:true,
			// 	deep:true,
			// 	handler(newValue,oldValue){
			// 		console.log('isHot被修改了',newValue,oldValue)
			// 	}
			// },
			//简写
			isHot(newValue,oldValue){
				console.log('isHot被修改了',newValue,oldValue)
			}
		}
	})
</script>
</html>